<?php

namespace App\Http\Controllers;

use App\Jobs\BrowseJob;
use App\Services\IndexService;
use Illuminate\Support\Facades\Redis;

class indexController extends Controller
{
    public function index()
    {
        $data = Redis::get('index_content');
        if (!$data) {
            $data = IndexService::indexCache();

            return view('index/index', $data);
        }

        $ip = \request()->ip();

        dispatch(new BrowseJob($ip));

        $data = json_decode($data, true);

        return view('index/index', $data);
    }
}
